package opgave3;

public class Identifier implements IdentifierInterface {

	private StringBuffer data;
	
	public Identifier () {
		data = new StringBuffer();
		data.append('a');
	}
	
	public Identifier (Identifier src) {
		data = new StringBuffer(src.data);
	}
	
	public void init(char c) {
		data = new StringBuffer();
		data.append(c);
	}

	public boolean equals(Identifier ident) {
		return data.toString().compareTo(ident.data.toString()) == 0;
	}

	public char getChar(int n) {
		return data.charAt(n);
	}
	
	public void addChar(char c) {
		data.append(c);
	}

	public int size() {
		return data.length();
	}
	
	public Identifier clone() {
		Identifier resultaat = new Identifier();
		
		resultaat.init(getChar(0));
		
		for(int i = 1; i < size(); i++) {
			resultaat.addChar(getChar(i));
		}
		
		return resultaat;
	}

	public int compareTo(Object o) {
		Identifier id = (Identifier)o;
		return data.toString().compareTo(id.data.toString());
	}
}
